    function NugRunning.OnAuraEvent(self, event, unit)
        if event == "UNIT_AURA" then
            local up = hUnits[unit]
            if not up then return end
            local unitGUID = UnitGUID(unit)
            if up == 2 and UnitGUID("target") == unitGUID then return end

            local now = GetTime()
            if up == 1 then --throttle target updates
                if now - last_taget_update < 200 then return end
            end


            for timer in pairs(active) do
                if timer.dstGUID == unitGUID and
                    (timer.timerType == "BUFF" or timer.timerType == "DEBUFF")
                then
                        local name, _,_, count, _, duration, expirationTime, caster, _,_, aura_spellID = UnitAura(unit, GetSpellInfo(timer.spellID), nil, timer.filter)
                        if UnitAffiliationCheck(caster, timer.opts.affiliation) and timer.spellID == aura_spellID then
                            if (now + duration - expirationTime < 0.1) then
                                NugRunning:RefreshTimer(playerGUID,unitGUID,UnitName(unit),nil, timer.spellID, timer.spellName, timer.opts, timer.timerType, duration, count, true)
                            elseif count and timer.count ~= count then
                                NugRunning:RemoveDose(playerGUID, unitGUID, aura_spellID, timer.spellName, timer.timerType, count)
                            end
                        end
                end
            end
        elseif event == "PLAYER_TARGET_CHANGED" then
            -- updating timers from target unit when possible
            local targetGUID = UnitGUID("target")
            if not targetGUID then return end
            table_wipe(targetTimers)
            for timer in pairs(active) do
                if timer.dstGUID == targetGUID then
                    -- if (timer.srcGUID == playerGUID or timer.opts.affiliation) then
                        table.insert(targetTimers, timer)
                    -- end
                else
                    if timer.opts.singleTarget then
                        free[timer] = true
                    end
                end
            end
            
            for _, filter in ipairs(filters) do
                for i=1,100 do
                    local name, _,_, count, _, duration, expirationTime, caster, _,_, aura_spellID = UnitAura("target", i, filter)
                    if not name then break end

                    local opts = config[aura_spellID]
                    if opts and UnitAffiliationCheck(caster, opts.affiliation) then
                        if opts.target and opts.target ~= "target" then return end
                        local found, timerType
                        -- searching in generated earlier table of player->target timers for matching spell
                        for _, timer in ipairs(targetTimers) do
                            if timer.spellID == aura_spellID then
                                found = true
                                timerType = timer.timerType
                                break
                            end
                        end
                        local newtimer
                        if found then
                            newtimer = NugRunning:RefreshTimer(playerGUID, targetGUID, UnitName("target"), nil, aura_spellID, name, config[aura_spellID], timerType, duration, count, true)
                        else
                            timerType = filter == "HELPFUL" and "BUFF" or "DEBUFF"
                            newtimer = NugRunning:ActivateTimer(playerGUID, targetGUID, UnitName("target"), nil, aura_spellID, name, config[aura_spellID], timerType, duration, count, true)
                        end
                        if newtimer then newtimer:SetTime( expirationTime - duration + newtimer.fixedoffset, expirationTime) end
                    end
                end
            end
        end
    end
    h:SetScript("OnEvent", NugRunning.OnAuraEvent)
    h:RegisterEvent("UNIT_AURA")
    h:RegisterEvent("PLAYER_TARGET_CHANGED")
end